package org.ko.core.web;

import javax.servlet.http.HttpServletRequest;

public abstract class BaseController {

	protected final String SUCCESS = "success";
	protected final String LIST = "list";
	protected final String EDIT = "edit";
	protected final String DELETE = "delete";
	protected final String SAVE = "save";
	protected final String VIEW = "view";
	/**分页key*/
	protected final String PAGINATION = "page";
	
	protected final String MESSAGE = "message";
	protected final String ADD = "add";
	
	protected final String ENTITY = "entity";
	
	/**
	 * 控制器对应的模板目录
	 * @return
	 */
	protected abstract String getTemplatePath();
	
	/**
	 * @param viewName
	 * @return
	 */
	protected String view(String viewName) {
		return getTemplatePath()+viewName;
	}
	protected String redirect(String viewName) {
		return "redirect:"+viewName;
	}
	
	/**
	 * 判断是否为GET形式的请求
	 * @param req
	 * @return
	 */
	protected boolean isGET(HttpServletRequest req){
		return req==null?false:req.getMethod().equalsIgnoreCase("get");
	}
	
}